package org.example.musicserver.controller;

import jakarta.annotation.Resource;
import org.example.musicserver.Request.SingerRequest;
import org.example.musicserver.common.Result;
import org.example.musicserver.service.SingerService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SingerController {

    @Resource
    private SingerService singerService;


    // 返回所有歌手
    @GetMapping("/singer")
    public Result allSinger(@RequestParam(required = false) String query) {
        return singerService.allSinger(query);
    }

    // 返回指定歌手ID的信息
    @GetMapping("/singer/detail")
    public Result songOfId(@RequestParam int id) {
        return singerService.singerOfId(id);
    }

    @DeleteMapping("/deletesinger")
    public Result deleteSinger(@RequestParam Integer id) {
        return singerService.deleteSinger(id);
    }

    //根据列表删除多个歌手
    @DeleteMapping("/deleteallsinger")
    public Result deleteSinger(@RequestParam List<Integer> singerIds) {
        return singerService.deleteSingers(singerIds);
    }

    @PostMapping("/addSinger")
    public Result addSinger(@RequestBody SingerRequest registryRequest) {
        return singerService.addSinger(registryRequest);
    }

    @PutMapping("/updateSinger")
    public Result updateSong(@RequestBody SingerRequest updateRequest) {
        return singerService.updateSinger(updateRequest);
    }
}
